﻿using System.Windows.Controls;
using System.Windows.Input;
using YY.Admin.Module;

namespace YY.Admin.Views.Control
{
    /// <summary>
    /// Interaction logic for Sidebar.xaml
    /// </summary>
    public partial class Sidebar : UserControl
    {
        public Sidebar()
        {
            InitializeComponent();
        }
        private void OnNavItemMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (sender is ListBoxItem item && item.DataContext is NavItem navItem)
            {
                // 执行命令（如果有）
                if (navItem.Command?.CanExecute(navItem) == true)
                {
                    navItem.Command.Execute(navItem);
                }

                // 如果不可选，阻止选中
                if (!navItem.IsActive)
                {
                    // 阻止 ListBox 自动选择该项
                    e.Handled = true;
                    return;
                }
            }
        }

    }
}
